﻿using System;
using System.Drawing;
using CI.Interfaces;

namespace CI.Organism
{
    /// <summary>Neural network system, eg add/del neuron</summary>
    public interface INeuralSystem : IDisposable
    {
        /// <summary>This is the workhorse of the neural system, this is where it runs through the neural network list executing neurons</summary>
        void Evaluate();

        /// <summary>Neural System Evaluation Start</summary>
        event Action NotifyEvaluationStart;
        // <summary>Neural System Evaluation Stop</summary>
        event Action NotifyEvaluationStop;

        /// <summary>Add a neuron to its neural network</summary>
        void AddNeuron(INeuron neuron);
        /// <summary>Delete a neuron to its neural network</summary>
        void DelNeuron(INeuron neuron);

        /// <summary>Organism the Neural system belongs to</summary>
        IOrganism Organism { get; set; }

        /// <summary>Neural network list waiting to be executed, adding neurons will cause them to be executed</summary>        
        INeuronCollection WaitingNeuralList { get; }

        /// <summary>
        /// List of neurons that where processed by the evaluate function
        /// To be used to look back at the list of neurons that have fired
        /// Clear at the begining of each time evaluate gets called
        /// </summary>
        INeuronCollection ProcessedNeuronList { get; }

        /// <summary>List of all the neurons in the neural system</summary>
        INeuronCollection Neurons { get; }

        /// <summary>List of all the Synapses in the neural system</summary>
        ISynapseCollection Synapses { get; }

        /// <summary>Mutate the current neural system</summary>
        void Mutate(double mutationRate, IOrganism parentOrganism);

        /// <summary>Neural System update handler</summary>
        event Action NeuralSystemUpdateHandler;

        void AddToWaitingList(INeuron neuron);
    }
}